<!DOCTYPE html>
<html>
<head>
    <title>录入住院信息</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="../Css/style.css" />
    <script type="text/javascript" src="../Js/jquery.js"></script>
<!--    <script type="text/javascript" src="../Js/jquery.sorted.js"></script>-->
    <script type="text/javascript" src="../Js/bootstrap.js"></script>
    <script type="text/javascript" src="../Js/ckform.js"></script>
    <script type="text/javascript" src="../Js/common.js"></script>
    <script type="text/javascript" src="../Js/ckeditor/ckeditor.js"></script>
 

    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
</head>
<body>
<form class="definewidth m20" id="myForm">
<table class="table table-bordered table-hover definewidth m10">
    <tr>
        <td width="10%" class="tableleft">病历号</td>
        <td><input id="key" type="text" name="hosR_id" placeholder="输入病历号回车自动带出挂号人信息"/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">姓名</td>
        <td><input type="text" name="hosR_name" placeholder="姓名"/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">证件类型</td>
        <td>身份证</td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">证件号</td>
        <td><input type="text" name="hosR_idCar" placeholder="身份证号"/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">社保号</td>
        <td><input type="text" name="hosR_medical" placeholder="社保号"/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">联系电话</td>
        <td><input type="text" name="hosR_phone" placeholder="联系电话"/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">是否自费</td>
        <td>
            <input type="radio" name="hosR_selfPrice" value="1" />否&nbsp;&nbsp;&nbsp;
            <input type="radio" name="hosR_selfPrice" value="0"/>是
        </td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">性别</td>
        <td>
            <input type="radio" name="hosR_sex" value="1" />男&nbsp;&nbsp;&nbsp;
            <input type="radio" name="hosR_sex" value="0"/>女</td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">年龄</td>
        <td><input type="text" name="hosR_age"/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">初复诊</td>
        <td>
            <input type="radio" name="hosR_lookDoctor" value="初诊" />初诊
            <input type="radio" name="hosR_lookDoctor" value="复诊"/>复诊
        </td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">所挂科室</td>
        <td>
            <select id="dept" name="dept">
                <option>请选择科室</option>
            </select>
        </td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">指定医生</td>
        <td>
            <select id="select" name="d_id">
                <option>请选择挂号医生</option>
            </select>
        </td>
    </tr>
	<tr>
        <td width="10%" class="tableleft">备注</td>
        <td><input type="text" name="hosR_remark"/></td>
	</tr>
    <tr>
        <td width="10%" class="tableleft">护理</td>
        <td><input type="text" name="beH_nursePeople"/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">床位号</td>
        <td><input type="text" name="beH_patBed"/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">缴费押金</td>
        <td><input type="text" name="beH_antecedent"/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">病情</td>
        <td><input type="text" name="beH_illness"></td>
    </tr>
    <tr>
        <td colspan="2">
			<center>
                <input type="button" onclick="stayChange()" class="btn btn-primary" value="保存"> &nbsp;&nbsp;<input  type="button" class="btn btn-success" id="backid" onclick="back()" value="返回列表">
			</center>
		</td>
    </tr>
</table>
</form>
<script>
    $("#key").keydown(function (){
        let uid = $("#key").val();
        $.ajax({
            url:"/patient/getPatientDetailById",
            data:{
                id:uid
            },
            method:"GET",
            dataType:"json",
            success:function (vo){
                let list = vo.list;
                let i=0;
                $(":text:eq(1)").val(list[i].patientName);
                $(":text:eq(2)").val(list[i].patientIdCard);
                $(":text:eq(3)").val(list[i].patientSocietyId);
                $(":text:eq(4)").val(list[i].patientPhoneNum);
                if(list[i].expenseWay=="否"){
                    $(":radio:eq(0)").attr("checked","checked");
                }else{
                    $(":radio:eq(1)").attr("checked","checked");
                }
                if(list[i].patientGender=="男"){
                    $(":radio:eq(2)").attr("checked","checked");
                }else{
                    $(":radio:eq(3)").attr("checked","checked");
                }
                $(":text:eq(5)").val(list[i].patientAge);
                if(list[i].patientFirst=="初诊"){
                    $(":radio:eq(4)").attr("checked","checked");
                }else{
                    $(":radio:eq(5)").attr("checked","checked");
                }
                $("#dept").val(list[i].patientDept);
                $("#select").val(list[i].doctor);
                $(":text:eq(6)").val(list[i].patientTip);
                $(":text:eq(7)").val(list[i].nurse);
                $(":text:eq(10)").val(list[i].condition);
            }
        })
        /*床位押金*/
        $.ajax({
            url:"/patient/forHospital",
            data:{
                id:uid
            },
            method:"GET",
            dataType:"json",
            success:function (vo){
                let list = vo.list;
                let i=0;
                $(":text:eq(8)").val(list[i].bedNumber);
                $(":text:eq(9)").val(list[i].deposit);
            }
        })
    })

    function back(){
        window.location.href="index.html";
    }

    function stayChange(){
        let uid = $("#key").val();
        $.ajax({
            url:"/patient/beInHospital",
            data:{
                id:uid
            },
            method:"GET",
            dataType:"json",
            success:function (vo){
                alert(vo.msg);
                back();
            }
        })
    }

    //dept下拉框填充
    $.ajax({
        url:"/dept/editList",
        method:"GET",
        dataType:"json",
        success:function (vo){
            var list = vo.list;
            for(var i = 0;i<list.length;i++){
                var deptName = list[i].deptName;
                var option = $("<option>").val(deptName).text(deptName);
                $("#dept").append(option);
            }
        }
    })
    //医生select下拉框填充
    $.ajax({
        url:"/Info/doctors",
        method:"GET",
        dataType:"json",
        success:function (vo){
            var list = vo.list;
            for(var i = 0;i<list.length;i++){
                var doctorName = list[i].doctorName;
                var option = $("<option>").val(doctorName).text(doctorName);
                $("#select").append(option);
            }
        }
    })
    // $(function () {
    //     loadFunction();
    //     //提交按钮的单击事件
    //     $("#btnAdd").click(function () {
    //         $.ajax({
    //             type: "GET",
    //             url: "/hos/add",
    //             data: $("#myForm").serialize(),
    //             dataType:"json",
    //             success: function(vo){
    //                 alert(1)
    //                 window.location.href = "/hospital/index.html";
    //             }
    //         });
    //     });
    // });
    // function loadFunction() {
    //     $.ajax({
    //         type: "get",
    //         url: "/doctor",
    //         data: null,
    //         dataType:"json",
    //         success: function(vo){
    //             console.log(vo);
    //             let doctorList=vo.list;
    //             var str="";
    //             for (var i = 0; i <doctorList.length; i++) {
    //                 str+='<option name="d_id" value="'+doctorList[i].doctorId+'">'+doctorList[i].doctorName+'</option>>';
    //             }
    //             $("#select").html(str);
    //         }
    //     });
    //     $.ajax({
    //         type: "get",
    //         url: "/dept/list",
    //         data: null,
    //         dataType:"json",
    //         success: function(vo){
    //             console.log(vo);
    //             let deptList=vo.list;
    //             var str="";
    //             for (var i = 0; i <deptList.length; i++) {
    //                 str+='<option value="'+deptList[i].deptId+'">'+deptList[i].deptName+'</option>>';
    //             }
    //             $("#dept").html(str);
    //         }
    //     });
    // }
</script>
</body>
</html>